The old contents of stuff.txt
are entirely replaced with the new output.
One way to send the output of a program to a printer is to redirect its output to a text file (as in the previous page), then read the file into Notepad or other editor, then use the editor's print command.
Here is a Hello.java
program that can be
copied to a source file and run to practice
redirection.
class Hello { public static void main ( String[] args ) { System.out.println("Hello World"); } }
Here is that program being used with output redirection:
C:\temp>javac Hello.java C:\temp>java Hello > output.txt C:\temp>type output.txt Hello World C:\temp>
After the above commands have been executed,
what happens to the file called output.txt
in
some other subdirectory such as C:\Myfiles
?